import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
import { TableColumn } from '@/types/table'
// 表单校验
export const rules = reactive({
                        title: [{ required: true, message: '试卷标题不能为空', trigger: 'blur' }],
                        franction: [{ required: true, message: '每个题型有多少  每个题多少分不能为空', trigger: 'blur' }],
                        price: [{ required: true, message: '试卷价格默认0不能为空', trigger: 'blur' }],
                        times: [{ required: true, message: '试卷时间单位分不能为空', trigger: 'blur' }],
                        isRepeat: [{ required: true, message: '重复答题 1可以 2否不能为空', trigger: 'blur' }]
})
//复杂配置参照文档修改
const crudSchemas = reactive<CrudSchema[]>([
  {
    label: 'ID',
    field: 'id',
    isSearch:  false ,
	isColumnHidden:  false 
  },
  {
    label: '试卷标题',
    field: 'title',
    isSearch:  true ,
	isColumnHidden:  false ,
	search: {
      componentProps: {
        style: {
          width: '240px'
        }
      }
    }
  },
  {
    label: '试卷类型',
    field: 'type',
    isSearch:  true ,
	isColumnHidden:  false ,
	dictType: DICT_TYPE.EXAM_PAPER_TYPE,
	dictClass: 'number',
	search: {
      componentProps: {
        style: {
          width: '240px'
        }
      }
    }
  },
  {
    label: '题型/分',
    field: 'franction',
    isSearch:  false ,
	isColumnHidden:  true 
  },
  {
    label: '试卷总分值',
    field: 'totalFranction',
    isSearch:  false ,
	isColumnHidden:  false 
  },
  {
    label: '试卷状态',
    field: 'status',
    isSearch:  true ,
	isColumnHidden:  false ,
	dictType: DICT_TYPE.COMMON_STATUS,
	dictClass: 'number',
	search: {
      componentProps: {
        style: {
          width: '240px'
        }
      }
    }
  },
  {
    label: '做题人数',
    field: 'dnum',
    isSearch:  false ,
	isColumnHidden:  true 
  },
  {
    label: '显示顺序',
    field: 'sort',
    isSearch:  false ,
	isColumnHidden:  false 
  },
  {
    label: '试卷价格',
    field: 'price',
    isSearch:  false ,
	isColumnHidden:  false 
  },
  {
    label: '试卷时间(分)',
    field: 'times',
    isSearch:  false ,
	isColumnHidden:  false 
  },
  {
    label: '可重复答题',
    field: 'isRepeat',
    isSearch:  false ,
	isColumnHidden:  true ,
	dictType: DICT_TYPE.INFRA_BOOLEAN_STRING,
	dictClass: 'number'
  },
  {
    label: '创建者',
    field: 'creator',
    isSearch:  false ,
	isColumnHidden:  true 
  },
  {
    label: '创建时间',
    field: 'createTime',
    isSearch:  true ,
	isColumnHidden:  false ,
	formatter: dateFormatter,
	search: {
		component: 'DatePicker',
      componentProps: {
		  valueFormat: 'YYYY-MM-DD HH:mm:ss',
        style: {
          width: '240px'
        }
      }
    }
  },
  {
    label: '更新者',
    field: 'updater',
    isSearch:  false ,
	isColumnHidden:  true 
  },
  {
    label: '更新时间',
    field: 'updateTime',
    isSearch:  false ,
	isColumnHidden:  true ,
	formatter: dateFormatter
  },
  {
    label: '操作',
    field: 'action',
    isForm: false,
    width: 240
  }
])
export const { allSchemas } = useCrudSchemas(crudSchemas)
